﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Linq;

namespace PairingMatrixService.Contract
{
    [DataContract]
    public class CardWallInstanceOnADate
    {
        public CardWallInstanceOnADate()
        {
            StorySignUps = new List<StorySignUp>();
            StandupTimeInSeconds = 0;
        }

        public CardWallInstanceOnADate(CardWallInstanceOnADate copyFrom)
        {
            Date = copyFrom.Date;
            StorySignUps = new List<StorySignUp>();
            copyFrom.StorySignUps.ForEach(
                s =>
                {
                    var storySignUp = new StorySignUp
                                      {
                                          Card = s.Card,
                                          CardPositionX = s.CardPositionX,
                                          CardPositionY = s.CardPositionY,
                                          CardNumber = s.CardNumber,
                                          StoryDevStage = s.StoryDevStage,
                                          Wall = s.Wall,
                                          Note = s.Note,
                                          SecondaryCards = s.SecondaryCards.Select(sec=>sec).ToList()
                                      };
                    s.Assignees.ForEach( a => storySignUp.Assignees.Add(new TeamMemberSummary {Id = a.Id, PositionX = a.PositionX, PositionY = a.PositionY}));
                    StorySignUps.Add(storySignUp);
                });
        }

        [DataMember]
        public DateTime Date;

        [DataMember]
        public int StandupTimeInSeconds;

        [DataMember]
        public List<StorySignUp> StorySignUps;

    }
}